package logdemo;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Scanner;

@Slf4j
public class LogDemo {
    // 获取日志对象
    private static final Logger LOGGER = LoggerFactory.getLogger(LogDemo.class);

    public static void main(String[] args) {
        // 打日志 -- 类似于输出语句
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入姓名：");
        String name = sc.nextLine();
        LOGGER.info("用户输入了姓名为：" + name);
        System.out.println("请输入年龄：");
        String age = sc.nextLine();
        try {
            int ageInt = Integer.parseInt(age);
            LOGGER.info("用户输入的年龄格式正确:" + age);
        } catch (NumberFormatException e) {
            LOGGER.info("用户输入的年龄格式错误:" + age);

        }
    }
}
